import { Dialog } from 'quasar'

export const FyDialog = {
  // 基础弹窗
  show(options = {}) {
    return Dialog.create({
      title: options.title || '提示',
      message: options.message,
      html: options.html,
      ok: {
        label: options.confirmText || '确定',
        color: 'primary',
      },
      cancel: options.showCancel !== false && {
        label: options.cancelText || '取消',
        color: 'grey-6',
      },
      persistent: options.persistent !== false,
      ...options,
    })
  },

  // 确认弹窗
  confirm(message, title = '确认') {
    return this.show({
      title,
      message,
      persistent: true,
    })
  },

  // 表单弹窗
  form(component, options = {}) {
    return Dialog.create({
      component,
      componentProps: options,
    })
  },
}

export default FyDialog
